package org.example.supplychain.mapper;

import org.apache.ibatis.annotations.*;
import org.example.supplychain.domain.Inventory;
import org.example.supplychain.domain.Material;

import java.util.List;

/**
 * 库存管理的Mapper
 */
@Mapper
public interface InventoryMapper {
    /**
     * 添加库存
     * @param inventory the inventory
     */
    @Insert("INSERT INTO inventory(inventory_name,inventory_place,inventory_manager) VALUES (#{inventoryName},#{inventoryPlace},#{inventoryManager})")
    void addInventory(Inventory inventory);

    /**
     * 删除库存
     * @param inventoryName the inventory name
     */
    @Delete("DELETE FROM inventory WHERE inventory_name = #{inventoryName}")
    void deleteInventoryByInventoryName(String inventoryName);

    /**
     * 更新库存
     * @param inventory the inventory
     */
    @Update("UPDATE inventory SET inventory_place = #{inventoryPlace},inventory_manager = #{inventoryManager} WHERE inventory_name = #{inventoryName}")
    void updateInventoryByInventoryName(Inventory inventory);

    /**
     * 根据库存名获取库存
     * @param inventoryName the inventory name
     * @return the inventory
     */
    @Select("SELECT * FROM inventory WHERE inventory_name = #{inventoryName}")
    Inventory getInventoryByInventoryName(String inventoryName);

    /**
     * 获取所有库存
     * @return the list
     */
    @Select("SELECT * FROM inventory")
    List<Inventory> getAllInventories();
}
